package com.oracle.oa.biz.impl;

import java.util.List;

import com.oracle.oa.biz.UserInfoBiz;
import com.oracle.oa.dao.UserInfoDao;
import com.oracle.oa.entity.Userinfo;


public class UserInfoBizImpl extends BaseBizImpl implements UserInfoBiz {

    UserInfoDao udao;
	
	public String login(Long id, String pwd) {
		String str="";
		Userinfo u = (Userinfo) udao.getById(Userinfo.class, id);
		if(u!=null ){
			if(pwd.equals(u.getPassword())){
				str="ok";
			}else{
				str="密码错误";
			}
		}else{
			str="用户不存在";
		}
		return str;
	}

	/**
	 * 得到用户总数
	 */
	
	public int getAllusercount() {
		int count=0;
		List<Userinfo> list = udao.getAll(Userinfo.class);
		if(list!=null&&list.size()>0){
			count=list.size();
		}
		return count;
	}


	
	public List getBydepartAndUserid(Object departname, Object userid) {
		return udao.getBydepartAndUserid(departname, userid);
	}


	
	public List getBydepartAndUsername(Object departname, Object username) {
		return udao.getBydepartAndUsername(departname, username);
	}


	
	public List getBydepartAndUsernameandUserid(Object departname,
			Object userid, Object username) {
		return udao.getBydepartAndUsernameandUserid(departname, userid, username);
	}


	
	public List getUseridAndUsername(Object userid, Object username) {
		return udao.getUseridAndUsername(userid, username);
	}
	public UserInfoDao getUdao() {
		return udao;
	}

	public void setUdao(UserInfoDao udao) {
		this.udao = udao;
	}

	
	public List<Userinfo> getByDeptId(Long deptid) {
		// TODO Auto-generated method stub
		return udao.getByDeptId(deptid);
	}

	
	public List<Userinfo> getByRoleid(Long roleid) {
		// TODO Auto-generated method stub
		return udao.getByRoleid(roleid);
	}

	
	public List<Userinfo> getByPorUsername(Object username) {
		return udao.getByPorUsername(username);
	}
}
